package com.suzhiliang.springbootlesson.servletDemo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Copyright (C), 2015-2018, XXX有限公司
 *
 * @ClassName: TestServlet
 * @Author: xmm
 * @Date: 2018/10/26 11:19
 * @Description: springBoot中自动转载Servlet测试类
 * @Version 1.0
 */
@WebServlet(urlPatterns = "/testServlet")
public class TestServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置返回类型是json格式
        resp.setContentType("application/json");
        //设置返回字符串值
        resp.setCharacterEncoding("utf-8");
        //输出对象
        PrintWriter printWriter = resp.getWriter();
        printWriter.write("执行TestServlet的doGet 成功");
        printWriter.close();
    }
}
